//
//  OrderDetailGiftsTableViewCell.m
//  KuWoCan
//
//  Created by 周小宏 on 2017/5/19.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "OrderDetailGiftsTableViewCell.h"
#import "OrderDetailListModel.h"

@interface OrderDetailGiftsTableViewCell ()

@property (nonatomic, strong) UIView *topBlankView;
@property (nonatomic, strong) UIImageView *labelImage;
@property (nonatomic, strong) UILabel *cargoDescription;
@property (nonatomic, strong) UIView *bottomBlankView;
@end

@implementation OrderDetailGiftsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.topBlankView = [[UIView alloc] init];
        [self.contentView addSubview:self.topBlankView];
        [self.topBlankView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.and.left.and.right.equalTo(self.contentView);
            make.height.equalTo(@0);
        }];

        self.labelImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gifts"]];
        [self.contentView addSubview:self.labelImage];
        self.labelImage.hidden = YES;
        [self.labelImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(20 * screenW_6);
            make.top.equalTo(self.topBlankView.mas_bottom);
            make.size.mas_equalTo(CGSizeMake(33 * screenW_6, 17 * screenW_6));
        }];

        self.cargoDescription = [[UILabel alloc] init];
        self.cargoDescription.font = KwFont(14 * screenW_6);
        self.cargoDescription.text = @"123";
        self.cargoDescription.numberOfLines = 0;
        [self.contentView addSubview:self.cargoDescription];
        [self.cargoDescription mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.labelImage.mas_right).offset(15 * screenW_6);
            make.top.equalTo(self.labelImage);
            make.right.equalTo(self.contentView).offset(-20 * screenW_6);
        }];

        self.bottomBlankView = [UIView new];
        [self.contentView addSubview:self.bottomBlankView];
        [self.bottomBlankView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.cargoDescription.mas_bottom);
            make.height.equalTo(@0);
            make.left.and.right.and.bottom.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)config:(OrderDetailListModel *)model {
    self.cargoDescription.text = [NSString stringWithFormat:@"%@ %@ %@ x%@", model.kwProductAttribute.product.productName, model.kwProductAttribute.tasteStr, model.kwProductAttribute.specificationsStr, model.quantity];
}

- (void)setTopBlankHeight:(CGFloat)height {
    [self.topBlankView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(height * screenW_6));
    }];
}

- (void)setBottomBlackHeight:(CGFloat)height {
    [self.bottomBlankView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(height * screenW_6));
    }];
}

- (void)showLabelImage {
    self.labelImage.hidden = NO;
}

- (void)hiddenLabelImage {
    self.labelImage.hidden = YES;
}

@end
